# Maintainer: David Sugar <tychosoft@gmail.com>
# Contributor: David Sugar <tychosoft@gmail.com>
pkgname=bordeaux
pkgver=0.9.2
pkgrel=0
pkgdesc="SIP telephony application server"
url="https://gitlab.com/tychosoft/bordeaux"
arch="all"
license="GPL-3.0-or-later"
makedepends="cmake fmt-dev>=8.1.0 flite-dev openssl-dev moderncli-dev>=0.9.4 webforcpp-dev>=0.1.1 libosip2-dev>=5.3.0 libexosip2-dev>=5.3.0"
subpackages="$pkgname-doc $pkgname-openrc $pkgname-coventry $pkgname-generic $pkgname-en_voices"
source="https://gitlab.com/tychosoft/bordeaux/-/archive/v$pkgver/bordeaux-v$pkgver.tar.gz bordeaux.initd bordeaux.confd"
builddir="$srcdir"/$pkgname-v$pkgver

build() {
	cmake \
		-DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc \
		-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=/var \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DCMAKE_INSTALL_SBINDIR=/usr/sbin \
		-DSERVER_PREFIX_PATH=/var/lib/bordeaux \
		-DSERVER_LOGGER_PATH=/var/log/bordeaux \
		-DSERVER_CONFIG_FILE=/etc/bordeaux.conf \
		-DCMAKE_BUILD_TYPE=Release .
	make
}

check() {
	make test
}

package() {
	DESTDIR="$pkgdir" make install
	install -d -m 750 -g adm "$pkgdir"/var/log/$pkgname
	install -d -m 700 "$pkgdir"/var/lib/$pkgname
	install -D -m 700 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -D -m 640 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -Dm644 LICENSE.md "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.md
	install -Dm644 README.md "$pkgdir"/usr/share/doc/$pkgname/README.md
	install -Dm644 FEATURES.md "$pkgdir"/usr/share/doc/$pkgname/FEATURES.md
}

en_voices() {
	pkgdesc="bordeaux default english voice"
	depends="bordeaux"
	amove usr/share/bordeaux/voices/en
	amove usr/lib/bordeaux/plugin_en.so
}

coventry() {
	pkgdesc="bordeaux coventry driver"
	depends="bordeaux"
	amove usr/lib/bordeaux/driver_coventry.so
}

generic() {
	pkgdesc="bordeaux generic driver"
	depends="bordeaux"
	amove usr/lib/bordeaux/driver_generic.so
}

sha512sums="
7fde37342c0db7cab1175d4eadd5eb23ecd44744a4a0f4d5991698978778f79511ea15a64133ab5d30cb6ba8465c2ee700ba137d00a8dfa8fe53b9f3eb9d7751  bordeaux-v0.9.2.tar.gz
59f169ed9df592500c5a7a76625c4cfe8dfd0269b514d5ac7afdb100cf44c26895d26de2c75a2c2e48dd57be89a30bf1fcffd580dda68d01f27e4d7bce0db940  bordeaux.initd
c6e67fbc38c8e75ea742e6b6204c8a0406b0f9226f0e667ee72c4e51bfa8d0fd45445ba160d1e7198ce509778abe94b6a86044e2aef86c31385f69f901570a1c  bordeaux.confd
"
